#include <stdio.h>

int seq_search(int array[], int n, int k, int seek_seq[]){
	for (int i = 0; i < n; i++){
		if(array[i] == k){
			seek_seq[i] = i;
			return 0;
		} else{
			seek_seq[i] = i;
		}
	}
	return -1;
}

int bin_search(int array[], int n, int k, int seek_seq[]){
	int low = 0;
	int high = n - 1;
	int i = 0;
	while(low <= high){
		int mid = (low + high) / 2;
		if(k > array[mid]){
			low = mid + 1;
			seek_seq[i] = mid;
		} else if(k < array[mid]){
			high = mid - 1;
			seek_seq[i] = mid;
		} else{
			seek_seq[i] = mid;
			return 0;
		}
		i++;
	}
	return -1;
}
int main() {
	int array[] = {0,1,2,3,4,5,6,7,8,9,10};
	int n = 10;
	int  k = 8;
	int seek_seq[10];
	for (int j = 0; j < n; j++) {
		seek_seq[j] = -1;
	}
	printf("查找成功返回0，失败返回-1，最终值为：%d\n", seq_search(array,n,k,seek_seq));
	printf("查找成功返回0，失败返回-1，最终值为：%d\n", bin_search(array,n,k,seek_seq));
}

